package main

import (
	"encoding/base64"
	"fmt"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
	"log"
	"os"
	"time"
)

type Blog struct {
	ID          uint   `gorm:"primary_key"`
	Title       string `gorm:"not null;size:256"`
	Content     string `gorm:"type:text;not null"`
	ShowContent string `gorm:"not null"`
	CreatedAt   time.Time
	LookNum     int `gorm:"default:1"`
	BlogType    BlogType
	BlogTypeID  int
}

type BlogType struct {
	ID   uint `gorm:"primary_key"`
	Name string
}

func ConnectMysql() *gorm.DB {
	db, err := gorm.Open("mysql", "root:python12@(127.0.0.1:3306)/gin_blog?charset=utf8mb4&parseTime=True&loc=Local")
	if err != nil {
		println("mysql连接错误", err)
		os.Exit(8520)
	}
	return db
}

func main() {
	input := []byte("156")

	// 演示base64编码
	encodeString := base64.StdEncoding.EncodeToString(input)
	fmt.Println(encodeString)

	// 对上面的编码结果进行base64解码
	decodeBytes, err := base64.StdEncoding.DecodeString(encodeString)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println(string(decodeBytes))
}
